import { Controller, Get, Post, ApiInfo, JwtUnless,ApiNoAuthRequired } from '@/libs/koa-action-decorator/index';
import { SuccessModel } from '@utils/respond/ResModel';
import { syncApi, getApiTree } from '../services/apiService';
import syncDatabase from '@db/sync';
export default
@ApiInfo({ name: '系统api接口', catalogue: '系统管理' })
@Controller('/api/admin/system/apis')
class ApiControllers {
  @Post('/syncApi')
  @JwtUnless
  @ApiInfo('同步系统api')
  async syncApi(ctx) {
    await syncApi();
    ctx.body = new SuccessModel({ msg: '同步成功😊😊😂😂' });
  }

  @Get('/getApiTree')
  @ApiInfo('获取api树形结构')
  async getApiTree(ctx) {
    ctx.body = await getApiTree();
  }

  @Get('/syncDataBase')
  @JwtUnless
  @ApiInfo('同步系统数据库模型')
  async syncDataBase(ctx) {
    syncDatabase();
    ctx.body = new SuccessModel({ msg: '同步成功😊😊😂😂' });
  }
}
